<?php
$url = $_SERVER["REQUEST_URI"];
$url_arr = explode('menu_id/',$url);
$menu_id = $url_arr[1]?$url_arr[1]:false;
?>
<div class="supplier-side-container">
    <div class="supplier-logo">
        <span class="logo {$menu_id}"><img src="{if $userinfo['logo']}{$userinfo['logo']}{else}/supplier/public/pc/images/new/default_logo.png{/if}"/></span>
    </div>
    {php $active_id = false;}
    <div class="supplier-nav">
        <div class="nav-list">
            {loop $menu $key $top}
            <div class="nav-item {$top['label']} {if !$menu_id}on{/if}" {if !$top['sub_menu']}data-url="{$top['url']}"{/if}>
            <span class="nav-tit"><i class="icon"></i>{$top['title']}{if $top['sub_menu']}<i class="arr"></i>{/if}</span>
            {if $top['sub_menu']}
            <ul class="nav-children" data-height="{php echo count($top['sub_menu'])*45}">
                {loop $top['sub_menu'] $sub}
                {if $menu_id==$sub['id']}
                {php $active_id = $sub['id']}
                {/if}
                <li class="menu_{$sub['id']} {if $menu_id==$sub['id']}active{/if}">
                    <a data-url="{$sub['url']}" href="javascript:;">{$sub['title']}</a>
                </li>
                {/loop}
            </ul>
            {/if}
        </div>
        {/loop}
    </div>
</div>
</div>
<script>
    var active_id = "{$active_id}";
    var obj = $('.menu_'+active_id);
    var ul_height = obj.parent().attr('data-height')
    obj.parent().css('height',ul_height)
    $(function(){
        $('.nav-children a,.nav-list .nav-item').on('click',function(){
            var url = $(this).attr('data-url');
            $('.iframe-body').attr('src',url);
        });
    })
</script>